package com.huxin.service;


import com.huxin.dao.Userdao;
import com.huxin.pojo.*;
import com.mysql.cj.x.protobuf.MysqlxDatatypes;

import java.util.ArrayList;
import java.util.List;

public class Userservice {
    private Userdao userdao=new Userdao();

    /**
     * 书本条件查询
     * @param conditionalQueryDTO
     * @return
     */
    public PageBean<BookStorage> booksSConditionalQueryByBid(ConditionalQueryDTO conditionalQueryDTO,Integer page,Integer size) {
        return userdao.booksSConditionalQueryByBid(conditionalQueryDTO,page,size);
    }
    public PageBean<BooksInfo> booksConditionalQueryByBid(ConditionalQueryDTO conditionalQueryDTO,Integer page,Integer size) {
        return userdao.booksConditionalQueryByBid(conditionalQueryDTO,page,size);
    }

    public int adduser(UserInfo userInfo) {
        return userdao.addUser(userInfo);
    }

    public UserInfo userLogin(String username,String password) {
       return userdao.userLogin(username,password);
    }

    public UserInfo selectById(Integer userId) {
        return userdao.selectById(userId);
    }

    public List<BookHisInfo> selectAllById(Integer aid) {
        return userdao.selectAllById(aid);
    }
    public List<BookHisInfo> selectAll() {
        return userdao.selectAll();
    }

    public int updateById(UserInfo userInfo) {
        return userdao.updateById(userInfo);
    }

    public boolean login(String username, String password) {
        return userdao.login(username,password);
    }

    public int updateservice(String id) {
         return userdao.updateservice(id);

    }

    public int updateBook(String id) {
        return userdao.updateBook(id);
    }

    public List<UserInfo> selectallreader() {
        return Userdao.selectallreader();
    }
    public PageBean<UserInfo> selectallreader(Integer page,Integer size) {
        return Userdao.selectallreader(page,size);
    }

    /**
     * 查询所有书籍
     * @return
     */
    public List<BooksInfo> topBooks() {
        return userdao.topBooks();
    }

    public BooksInfo selectBookById(Integer bid) {
        return userdao.selectBookdById(bid);
    }

    public int insertBorrowbook(BookHisInfo bookHisInfo) {
        return userdao.insertBorrowbook(bookHisInfo);
    }

    public int decreaseUserNum(Integer aid) {
        return userdao.decreaseUserNum(aid);
    }

    public int decreaseBookNum(Integer bid) {
        return userdao.decreaseBookNum(bid);
    }

    public int addFrequency(Integer userId) {
        return userdao.addFrequency(userId);
    }

    public int Delectservice(String id) {
        return  Userdao.Delectservice(id);
    }

    public int updateUser(UserInfo reader) {
        return  Userdao.updateUser(reader);
    }



    public UserInfo findReadById(String aid) {
        return Userdao.findReadById(aid);
    }

    public void addUserMaxNum(Integer aid) {
        userdao.addUserMaxNum(aid);
    }

    public List<UserInfo> selectAllOrderByFrequency() {
      return userdao.selectAllOrderByFrequency();
    }

    public List<BooksInfo> selectAllBooks() {
        return userdao.selectAllBooks();
    }

    /**
     * 根据作者名查询书籍
     * @param conditionalQueryDTO
     * @return
     */
    public PageBean<BooksInfo> booksConditionalQueryByAuthor(ConditionalQueryDTO conditionalQueryDTO,Integer page,Integer size) {
        return userdao.booksConditionalQueryByAuthor(conditionalQueryDTO,page,size);
    }
    public PageBean<BookStorage> booksConditionalQueryByAuthor1(ConditionalQueryDTO conditionalQueryDTO,Integer page,Integer size) {
        return userdao.booksConditionalQueryByAuthor1(conditionalQueryDTO,page,size);
    }

    /**
     * 根据分类查询书籍
     * @param conditionalQueryDTO
     * @return
     */
    public PageBean<BooksInfo> booksConditionalQueryByType(ConditionalQueryDTO conditionalQueryDTO,Integer page,Integer size) {
       return userdao.booksConditionalQueryByType(conditionalQueryDTO,page,size);
    }
    public PageBean<BookStorage> booksSConditionalQueryByType(ConditionalQueryDTO conditionalQueryDTO,Integer page,Integer size) {
        return userdao.booksSConditionalQueryByType(conditionalQueryDTO,page,size);
    }

    public PageBean<BooksInfo> booksConditionalQueryByName(ConditionalQueryDTO conditionalQueryDTO,Integer page,Integer size) {
        return userdao.booksConditionalQueryByName(conditionalQueryDTO,page,size);
    }
    public PageBean<BookStorage> booksSConditionalQueryByName(ConditionalQueryDTO conditionalQueryDTO,Integer page,Integer size) {
        return userdao.booksSConditionalQueryByName(conditionalQueryDTO,page,size);
    }

    public PageBean<BookHisInfo> findAllById(Integer userId, int page, int size) {
        return userdao.findAllById(userId,page,size);
    }
    public PageBean<BookHisInfo> findAll( int page, int size) {
        return userdao.findAll(page,size);
    }
    public PageBean<BooksInfo> findAllBooks(int page, int size) {
        return userdao.findAllBooks(page,size);
    }
    public PageBean<BookStorage> findAllBooksS(int page, int size) {
        return userdao.findAllBooksS(page,size);
    }

    public PageBean<BookStorage> findAllBookStorage(int page, int size) {
        return userdao.findAllBookStorage(page,size);
    }

    public void addBookHisCard(Integer bid) {
        userdao.addBookHisCard(bid);
    }

    /**
     * 用户提交问题
     * @param problemFeedback
     * @return
     */
    public int submitProblem(ProblemFeedback problemFeedback) {
        return userdao.submitProblem(problemFeedback);
    }

    /**
     * 根据用户id查询反馈的问题
     * @param username
     * @return
     */
    public List<ProblemFeedback> getFeedbackById(String username) {
        return userdao.getFeedbackById(username);
    }

    public int delectbooktype(String id) {
        return Userdao.delectbooktype(id);
    }
    public int Addtype(BookTypeInfo type) {
        return Userdao.Addtype(type);
    }
    public PageBean<BookTypeInfo> selectalltype(Integer page,Integer size) {
        return  Userdao.selectalltype(page,size);
    }

    /**
     * 根据用户登录账号查询用户
     * @param username
     * @return
     */
    public PageBean<UserInfo> selectUserByUsername(String username,Integer page,Integer sezi) {
        return userdao.selectUserByUsername(username,page,sezi);
    }

    /**
     * 根据用户名查询用户
     * @param name
     * @return
     */
    public PageBean<UserInfo> selectUserByname(String name,Integer page,Integer sezi) {
        return userdao.selectUserByname(name,page,sezi);
    }

    /**
     * 管理员登录
     * @param adminInfo
     * @return
     */
    public AdminInfo adminLogin(AdminInfo adminInfo) {
        return userdao.adminLogin(adminInfo);
    }

    /**
     * 查询书籍所有分类
     * @return
     */
    public List<BookTypeInfo> getBookType() {
        return userdao.getBookType();
    }

    /**
     * 添加书籍
     * @param booksInfo
     * @return
     */
    public int addBooks(BooksInfo booksInfo) {
        return userdao.addBooks(booksInfo);
    }


    public int deleteBookdsById(String ids) {
        return userdao.deleteBookdsById(ids);
    }

    public BookTypeInfo selectBooksTypeName(String id) {
        return userdao.selectBooksTypeName(id);
    }

    public List<BooksInfo> selectBooksByTpyeName(String typeName) {
        return userdao.selectBooksByTpyeName(typeName);
    }

    public List<ProblemFeedback> getAllProblem() {
        return userdao.getAllProblem();
    }

    public int updateProblemStatus(String pid) {
        return userdao.updateProblemStatus(pid);
    }

    public int deleteProblemById(String pid) {
        return userdao.deleteProblemById(pid);
    }

    public int updateAdminPwd(AdminInfo adminInfo) {
        return userdao.updateAdminPwd(adminInfo);
    }

    public PageBean<BookHisInfo> findAllbyBid(ConditionalQueryDTO conditionalQueryDTO,Integer page,Integer size) {
        return userdao.findAllbyBid(conditionalQueryDTO,page,size);
    }
    public PageBean<BookHisInfo> findAllbyBid(ConditionalQueryDTO conditionalQueryDTO,Integer aid) {
        return userdao.findAllbyBid(conditionalQueryDTO,aid);
    }

    public PageBean<BookHisInfo> findAllbyUserName(ConditionalQueryDTO conditionalQueryDTO, int page, int size) {
        return userdao.findAllbyUserName(conditionalQueryDTO,page,size);
    }

    /**
     * 根据用户id条件查询
     * @param conditionalQueryDTO
     * @param aid
     * @return
     */
    public PageBean<BookHisInfo> findAllbyUserName(ConditionalQueryDTO conditionalQueryDTO,Integer aid) {
        return userdao.findAllbyUserName(conditionalQueryDTO,aid);
    }


    public PageBean<BookHisInfo> findAllbyBookName(ConditionalQueryDTO conditionalQueryDTO, int page, int size) {
        return userdao.findAllbyBookName(conditionalQueryDTO,page,size);
    }
    public PageBean<BookHisInfo> findAllbyBookName(ConditionalQueryDTO conditionalQueryDTO,Integer aid) {
        return userdao.findAllbyBookName(conditionalQueryDTO,aid);
    }

    public int updateBookById(BooksInfo booksInfo) {
        return userdao.updateBookById(booksInfo);
    }

    public BookHisInfo findBookHisInfoById(String hid) {
        return userdao.findBookHisInfoById(hid);
    }

    public int deleteBookHisInfoByHid(String hid) {
        return userdao.deleteBookHisInfoByHid(hid);
    }

    public int updateBookHisInfoByHid(BookHisInfo bookHisInfo) {
        return userdao.updateBookHisInfoByHid(bookHisInfo);
    }


    public PageBean<Bookreservation> selectallById(Integer userId, int page, int size) {
        return userdao.selectallById(userId,page,size);
    }


    public PageBean<Bookreservation> findById(Integer userId, int page, int size) {
        return userdao.findById(userId,page,size);
    }

    public PageBean<Bookreservation> findbyBid(ConditionalQueryDTO conditionalQueryDTO, Integer userId) {
        return userdao.findbyBid(conditionalQueryDTO,userId);
    }

    public PageBean<Bookreservation> findbyBookName(ConditionalQueryDTO conditionalQueryDTO, Integer userId) {
        return userdao.findbyBookName(conditionalQueryDTO,userId);
    }

    public PageBean<Bookreservation> selectallreservation(int page, int size) {
        return userdao.selectallreservation(page,size);
    }

    public PageBean<Bookreservation> findAllreservation(int page, int size) {
        return userdao.findAllreservation(page,size);
    }

    public PageBean<Bookreservation> findAllbyBookId(ConditionalQueryDTO conditionalQueryDTO) {
        return userdao.findAllbyBookId(conditionalQueryDTO);
    }

    public PageBean<Bookreservation> findAllbyBook(ConditionalQueryDTO conditionalQueryDTO) {
        return userdao.findAllbyBook(conditionalQueryDTO);
    }

    public PageBean<Bookreservation> findbyUserName(ConditionalQueryDTO conditionalQueryDTO) {
        return userdao.findbyUserName(conditionalQueryDTO);
    }
    public List<Bookreservation> selectAllreservation() {
        return userdao.selectAllreservation();
    }

    public int insertReservebook(Bookreservation bookreservation) {
        return userdao.insertReservebook(bookreservation);
    }

    public int delectereservation(int bid) {
        return userdao.delectereservation(bid);
    }

    public int addhisinfo(BookHisInfo bookHisInfo) {
        return userdao.addhisinfo(bookHisInfo);
    }

    public int delectbookinfo(Integer bid) {
        return  userdao.delectbookinfo(bid);
    }

    public int cancelbooks(Integer bid) {
        return userdao.cancelbooks(bid);
    }

    public int  updateBookHisInfoEndTimeByHid(BookHisInfo bookHisInfo) {
        return userdao.updateBookHisInfoEndTimeByHid(bookHisInfo);
    }

    public int updateUserStatus(String id) {
        return userdao.updateUserStatus(id);
    }
    public int updateUserStatusTure(String id) {
        return userdao.updateUserStatusTure(id);
    }

    public int addBookNum(Integer bid) {
        int i = userdao.addBookNum(bid);
        return i;
    }

    public int AdminAgreeUser(String aid) {
        return userdao.AdminAgreeUser(aid);
    }

    public int AdminAgreeUserAll() {
        return userdao.AdminAgreeUserAll();
    }

    /**
     * 根据书名和作者查询书籍
     * @param booksInfo
     * @return
     */
    public BooksInfo findBookByNameAndAuthor(BooksInfo booksInfo) {
        return userdao.findBookByNameAndAuthor(booksInfo);
    }

    /**
     * 根据书名和作者增加书籍
     * @param booksInfo
     * @return
     */
    public int addBookNumByNameAndAuthor(BooksInfo booksInfo) {
        return userdao.addBookNumByNameAndAuthor(booksInfo);
    }

    /**
     * 增加书籍入库信息
     * @param bookStorage
     * @return
     */
    public int addBookStorage(BookStorage bookStorage) {
        return userdao.addBookStorage(bookStorage);
    }

    /**
     * 查询所有未归还的信息
     * @return
     */
    public PageBean<BookHisInfo> findAllNotReturn(Integer page,Integer size) {
        return userdao.findAllNotReturn(page,size);
    }

    public UserInfo getUserName(UserInfo userInfo) {
        return userdao.getUserName(userInfo);
    }

    /**
     * 根据 aid删除用户书籍
     * @param aid
     * @return
     */
    public int deleteUser(String aid) {
        return userdao.deleteUserByAid(aid);
    }
}
